package com.bawei.system.remote.api;

import com.bawei.common.core.constant.ServiceNameConstants;
import com.bawei.common.core.domain.R;
import com.bawei.system.remote.factory.RemoteEsDocFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 全文检索服务
 *
 * @author bawei
 */
@FeignClient(contextId = "remoteEsIndexService", value = ServiceNameConstants.ES_SERVICE, fallbackFactory = RemoteEsDocFallbackFactory.class)
public interface RemoteEsIndexService {
    /**
     * 根据索引名称创建索引
     *
     * @return
     */
    @GetMapping("/esIndex/create")
    public R<Boolean> indexCreate(@RequestParam("indexName") String indexName);

    /**
     * 根据索引名称、映射结构创建索引
     *
     * @return
     */
    @GetMapping("/esIndex/createWithMapping")
    public R<Boolean> indexCreateWithMapping(@RequestParam("indexName") String indexName,@RequestParam("indexMapping") String indexMapping);

    /**
     * 根据索引名称查询索引是否存在
     *
     * @return
     */
    @GetMapping("/esIndex/indexExit")
    public R<Boolean> indexExit(@RequestParam("indexName") String indexName);

    /**
     * 根据索引名称删除索引
     *
     * @return
     */
    @GetMapping("/esIndex/indexDelete")
    public R<Boolean> indexDelete(@RequestParam("indexName") String indexName);

    /**
     * 根据索引名称获取mapping
     *
     * @return
     */
    @GetMapping("/esIndex/indexGetMapping")
    public R<Map> indexGetMapping(@RequestParam("indexName") String indexName);
}
